<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!doctype html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="copyright" content=""/>
    <meta name="keywords" content=""/>
    <meta name="description" content=""/>
    <title>注册第四步</title>
    <link href="../favicon.ico" rel="shortcut icon">
	<link href="https://cdn.jsdelivr.net/gh/bootcdn/BootCDN/ajax/libs/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
	<link href="${pageContext.request.contextPath}/css/system/public.css" />
    <link href="${pageContext.request.contextPath}/css/system/register.css" />
</head>
<body class="s_body k_body">
	<ul class="s_header">
        <li><img src="${pageContext.request.contextPath}/images/system/s_logo.png" /></li>
        <li><a href="http://cecook.cn">首页</a></li>
        <%-- <li><a href="${pageContext.request.contextPath}/ui/home">首页</a></li> --%>
        <li><a href="javascript:;">产品优势</a></li>
        <li><a href="javascript:;">成为代理商</a></li>
        <li><a href="javascript:;">联系我们</a></li>
        <li class="s_header_on"><a href="${pageContext.request.contextPath}/ui/loginPwd">登录</a></li>
        <li><a href="${pageContext.request.contextPath}/ui/registerOne">申请试用</a></li>
    </ul>
    <div class="s_content">
        <h3><span>4</span><p>/4</p> 请输入您关注的线索关键字<i>(最多5个关键字)</i></h3>
        <div class="s_login_box s_keyword">
            <div class="key fix" id="key_d">
                <!--<div>
                    <div>旅游<img class="del" src="images/del.png"/></div>
                </div>-->
            </div>
            <div class="form">
               <input type="text" placeholder="请输入关键字" id="key" maxlength="30">
                <span>Enter确认</span>
            </div>
            <div id="warning_word" style="color:red;text-align:center;"></div>
            <div class="btnDiv"><a href="javascript:;" class="s_dl_button disabled">完 成</a><b>完 成</b></div>
            <a href="javascript:;" class="s_skip">跳过></a>
        </div>
    </div>
    <div class="s_footer">
        <p>zhfeat</p>
    </div>
    <!-- 注册完成审核弹框 -->
     <div class="s_popup">
        <div class="issue">
            <span><img src="${pageContext.request.contextPath}/images/system/s_close.png" /></span>
            <h4><img src="${pageContext.request.contextPath}/images/system/icon_hint.png" /> 注册信息提交成功</h4>
            <p>您提交的注册信息会在3个工作日内完成审核， 请注意接听客服电话</p>
            <a href="javascript:;" class="s_btns">确定</a>
        </div>
    </div>

 <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<script>
$('.issue span').click(function(){
    $('.s_popup').hide();
    $('.issue').hide();
});
$('.s_keyword input').focus(function(){
    $(this).addClass('focus');
});
$('.s_keyword input').blur(function(){
    $(this).removeClass('focus');
});
$('.s_keyword input').on('keydown',function(e){

    if(e.keyCode==13){
        var keyword = $.trim($('.s_keyword input').val());
        var key_w="";
		$('#key_d>div').each(function(){
			key_w = $(this).text();
			if(keyword==key_w){
				wword.text("不能输入重复的关键字");
				keyword="";            				
			}               			
  		}); 
        $(this).parents('.s_keyword').find('span').show();
        var html = "";
        var len = $('.key>div').length;
        var newLen = $('.key>div').length;
        if(len>=4){
            $('.form').css('visibility','hidden');
        }
        if(!keyword==""){
            if(len>=5){
                return false;
            }
            wword.text("");
            html = "<div><div>"+keyword+"<img class='del' src='${pageContext.request.contextPath}/images/system/del.png'/></div></div>"
        }
        $('.key').append(html);
        $('.s_keyword input').val('');
        $('.s_dl_button').removeClass('disabled');
        $('.btnDiv b').hide();
        $(this).parents('.s_keyword').find('span').hide();
    }
});
$('body').on('click','.del',function(){
    $('.form').css('visibility','visible');
    $(this).parent().parent().remove();
    var len = $('.key>div').length;
    if(len==0){
        $('.s_dl_button').addClass('disabled');
        $('.btnDiv b').show();
    }
});
//点击跳过
var wword = $("#warning_word");
$(function(){
	$('.s_skip').click(function(){
	   var url = "${pageContext.request.contextPath}/api/register/finish";
       $.ajax({
           type: "POST",
           url: "${pageContext.request.contextPath}/api/register/finish",
           success: function(data){
        	   if ("1" == data.error_code) {
	               $('.s_popup,.issue').show().delay(3000).fadeOut(function(){
    	           window.location.href="${pageContext.request.contextPath}/ui/loginPwd";
	               });
				} else {
					/* 显示错误 */
					wword.text(data.message);
				}
           }
       });
	});  
});	
//点击完成，点击事件
$(function(){
	$('.btnDiv').click(function(){
        //$('.s_popup').show();
        //$('.issue').show();
		//关键字 	
		var keyWord = "";
		$('#key_d>div').each(function(){
		  keyWord += $(this).text()+",";
		});   //alert(keyWord);
 	    var url = "${pageContext.request.contextPath}/api/company/infoKeyUpdate";
 	    var params = {"keyWord":keyWord};
 	    $.ajax({
 	    	type: "POST",
	        url: "${pageContext.request.contextPath}/api/company/infoKeyUpdate",
	        data: params,
	        dataType: "json",
	        success: function(data){
	            if ("1" == data.error_code) {
	                $('.s_popup,.issue').show().delay(3000).fadeOut(function(){
	    	        window.location.href="${pageContext.request.contextPath}/ui/loginPwd";
   	            });
				} else {
					/* 显示错误 */
					wword.text(data.message);
				}   	                	
	        } 
 	   }); 
    }); 
 }); 	    	   
 </script>    
</body>
</html>

